package Sort;

import java.lang.reflect.Array;
import java.util.Arrays;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}15:55
 */
public class selectSort {
    public static void main(String[] args) {
        int[] arr = {1,5,8,6,4,2,3};
        sort(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void sort(int[] arr){
       for(int i = 0; i < arr.length; i++){
           int index = i;
           int temp = 0;
           for (int j = i;j < arr.length; j++){
               if (arr[index] > arr[j]){
                   index = j;
               }
           }
           if (index != i){
               temp = arr[i];
               arr[i] = arr[index];
               arr[index] = temp;
           }
       }
    }
}
